<?php
class InfoNavModel extends Model {

    protected $_validate = array(
        array('name', '2,20', '导航名称长度必须为2~20位', 0, 'length'),
        array('info', '0,255', '导航描述长度必须在255位以内!', 0, 'length')
    );

    protected $_auto = array(
        array('attr', 'createAttr', 3, 'callback'),
        array('sort', 'createSort', 1, 'callback'),
        array('pid', 'createPid', 1, 'callback')
    );

    public function createAttr() {
        if(!empty($_POST['attr'])) {
            return implode(',', $_POST['attr']);
        } else {
            return '';
        }
    }

    public function createSort() {
        $tmp = $this->query("SHOW TABLE STATUS LIKE '__TABLE__'");
        return $tmp[0]['Auto_increment'];
    }

    public function createPid() {
        if(isset($_GET['pid'])) {
            return $_GET['pid'];
        } else {
            return 0;
        }
    }



}


?>